package com.sskj.lib.http;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.request.PostRequest;
import com.sskj.common.base.HttpData;
import com.sskj.lib.bean.ArticleBean;
import com.sskj.lib.bean.BorrowMoneyRecordBean;
import com.sskj.lib.bean.CertificationBean;
import com.sskj.lib.bean.CurrentRecordBean;
import com.sskj.lib.bean.CurrentTypeBean;
import com.sskj.lib.bean.FrashBean;
import com.sskj.lib.bean.FrashDataBean;
import com.sskj.lib.bean.FunctionsBannerBean;
import com.sskj.lib.bean.HeaderBean;
import com.sskj.lib.bean.CurrentTreasureBean;
import com.sskj.lib.bean.HotBean;
import com.sskj.lib.bean.IncomeDetailBean;
import com.sskj.lib.bean.NoticeBean;
import com.sskj.lib.bean.PageBean;
import com.sskj.lib.bean.PledgeBean;
import com.sskj.lib.bean.PledgeInterestBean;
import com.sskj.lib.bean.ShareBean;
import com.sskj.lib.bean.ShiftBean;
import com.sskj.lib.bean.SignInListBean;
import com.sskj.lib.bean.StrategyBean;
import com.sskj.lib.bean.TextDetailsBean;
import com.sskj.lib.bean.UsableBean;

import java.io.File;
import java.util.List;

/**
 *
 */
public class HttpService {


    /**
     * 实名认证@
     *
     * @param img1 图片1
     * @param img2 图片2
     * @param img3 图片3
     * @param img4 图片4
     * @return
     */
    public PostRequest<HttpData> homeUsersSetAut(String img1, String img2, String img3, String img4) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.HOME_USERS_SET_AUT)
                .params("img1", img1)
                .params("img2", img2)
                .params("img3", img3)
                .params("img4", img4)
                ;
    }


    /**
     * 热门列表
     *
     * @param p
     * @param size
     * @return
     */
    public PostRequest<HttpData<HotBean>> getHotList(int p, String size) {
        return OkGo.<HttpData<HotBean>>post(HttpConfig.BASE_URL + HttpConfig.COMMUNITY_HOT_LIST)
                .params("p", p)
                .params("size", size);
    }

    /**
     * 热门列表
     *
     * @param p
     * @param size
     * @return
     */
    public PostRequest<HttpData<HotBean>> getHotListLogin(int p, String size) {
        return OkGo.<HttpData<HotBean>>post(HttpConfig.BASE_URL + HttpConfig.COMMUNITY_HOT_LIST_LOGIN)
                .params("p", p)
                .params("size", size);
    }

    public PostRequest<HttpData<NoticeBean>> getNoticeList(int p, String size) {
        return OkGo.<HttpData<NoticeBean>>post(HttpConfig.BASE_URL + HttpConfig.COMMUNITY_NOTICE_LIST)
                .params("p", p)
                .params("size", size);
    }

    /**
     * 投资列表
     *
     * @param pay_type 币种标识
     * @param page     1策略投资2借币投资
     * @param type     页码
     * @return
     */
    public PostRequest<HttpData<StrategyBean>> getStrategyData(String pay_type, String type, String page, String languages) {
        return OkGo.<HttpData<StrategyBean>>post(HttpConfig.BASE_URL + HttpConfig.FUNCTIONS_STRATEGY_LIST)
                .params("pay_type", pay_type)
                .params("languages", languages)
                .params("type", type)
                .params("page", page);
    }

    public PostRequest<HttpData<CurrentRecordBean>> getRecordData(int page, int size) {
        return OkGo.<HttpData<CurrentRecordBean>>post(HttpConfig.BASE_URL + HttpConfig.FUNCTIONS_CURRENT_RECORD)
                .params("page", page)
                .params("size", size);
    }

    /**
     * 登录
     *
     * @param username 用户名
     * @param pwd      密码
     * @return
     */
    public PostRequest<HttpData<HeaderBean>> login(String username, String pwd) {
        return OkGo.<HttpData<HeaderBean>>post(HttpConfig.BASE_URL + HttpConfig.LOGIN)
                .params("mobile", username)
                .params("opwd", pwd);
    }

    public PostRequest<HttpData> startInvest(String price, String id, String pwd) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.FUNCTIONS_INVEST)
                .params("price", price)
                .params("id", id)
                .params("pwd", pwd);
    }

    /**
     * 闪兑界面数据
     *
     * @param type 类型
     * @return
     */
    public PostRequest<HttpData<FrashDataBean>> getFrashData(String type) {
        return OkGo.<HttpData<FrashDataBean>>post(HttpConfig.BASE_URL + HttpConfig.FUNCTIONS_FRASH_URL)
                .params("type", type);
    }

    public PostRequest<HttpData> onSureExchange(String type, String pwd, String price) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.FUNCTIONS_FRASH_EXCHANGE)
                .params("type", type)
                .params("pwd", pwd)
                .params("price", price);
    }

    /**
     * 低压利率
     *
     * @param today 天数
     * @return
     */
    public PostRequest<HttpData<PledgeInterestBean>> getPledgeInterest(String today) {
        return OkGo.<HttpData<PledgeInterestBean>>post(HttpConfig.BASE_URL + HttpConfig.FUNCTIONS_PLEDGE_INTEREST)
                .params("today", today);
    }

    public PostRequest<HttpData> startPledge(String tv1
            , String pledgeStateOne
            , String s1
            , String pledgeStateTwo
            , String string
            , String toString
            , String procedures
            , String s
            , String tv
            , String pwd) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.FUNCTIONS_START_PLEDGE)
                .params("mortgage_price", tv1)
                .params("mortgage_type", pledgeStateOne)
                .params("borrow_price", s1)
                .params("borrow_type", pledgeStateTwo)
                .params("borrow_term", string)
                .params("borrow_interest_rate", toString)
                .params("service_charge", procedures)
                .params("loan_handling_fee", s)
                .params("interest", tv)
                .params("pwd", pwd);
    }

    /**
     * 活期宝数据
     *
     * @param type 类型
     * @return
     */
    public PostRequest<HttpData<CurrentTreasureBean>> getCurrentTreasureData(String type, String language) {
        return OkGo.<HttpData<CurrentTreasureBean>>post(HttpConfig.BASE_URL + HttpConfig.CURRENT_TREASURE)
                .params("type", type)
                .params("languages", language);
    }


    /**
     * 活期宝货币类型
     *
     * @return
     */
    public PostRequest<HttpData<List<String>>> getCurrentType() {
        return OkGo.<HttpData<List<String>>>post(HttpConfig.BASE_URL + HttpConfig.CURRENT_TYPE);
    }


    /**
     * 抵押借币天数及借币说明
     *
     * @param languages 1.中文2.英文
     * @return
     */
    public PostRequest<HttpData<PledgeBean>> getTimeData(String languages) {
        return OkGo.<HttpData<PledgeBean>>post(HttpConfig.BASE_URL + HttpConfig.FUNCTIONS_PLEDG_TIME)
                .params("languages", languages);
    }

    /**
     * @param
     * @param type
     * @return
     */
    public PostRequest<HttpData<ShiftBean>> getShiftToData(String type, String ptype) {
        return OkGo.<HttpData<ShiftBean>>post(HttpConfig.BASE_URL + HttpConfig.FUNCTIONS_SHIFT_BALANCE)
                .params("type", type)
                .params("ptype", ptype);
    }

    //转入转出
    public PostRequest<HttpData> shiftToMoney(String type, String price, String pwd) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.FUNCTIONS_SHIFT_TO_MONEY)
                .params("type", type)
                .params("price", price)
                .params("pwd", pwd);
    }

    public PostRequest<HttpData> getRollOut(String type, String price, String pwd) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.FUNCTIONS_ROLL_OUT_MONEY)
                .params("type", type)
                .params("price", price)
                .params("pwd", pwd);
    }

    /**
     * 签到状态
     *
     * @param
     * @return
     */
    public PostRequest<HttpData> getSignInState() {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.SIGN_IN_STATE);
    }

    /**
     * 签到
     *
     * @param p
     * @param size
     * @return
     */
    public PostRequest<HttpData<SignInListBean>> getSignInList(String p, String size) {
        return OkGo.<HttpData<SignInListBean>>post(HttpConfig.BASE_URL + HttpConfig.SIGN_IN_LIST)
                .params("p", p)
                .params("size", size);
    }

    /**
     * 借币生息记录
     *
     * @return
     */
    public PostRequest<HttpData<BorrowMoneyRecordBean>> getJbsxList(String type, String page, String size) {
        return OkGo.<HttpData<BorrowMoneyRecordBean>>post(HttpConfig.BASE_URL + HttpConfig.FUNCTIONS_BorrowMoneyRecord)
                .params("type", type)
                .params("page", page)
                .params("size", size);
    }

    /**
     * 闪兑记录
     *
     * @return
     */
    public PostRequest<HttpData<FrashBean>> getFrashList(int page, int size) {
        return OkGo.<HttpData<FrashBean>>post(HttpConfig.BASE_URL + HttpConfig.FUNCTIONS_FRASH)
                .params("page", page)
                .params("size", size);
    }

    /**
     * 点击签到
     *
     * @return
     */
    public PostRequest<HttpData> clickSignIn() {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.CLICK_SIGN_IN);
    }

    /**
     * 找回密码
     *
     * @param number        手机号
     * @param loginPassword 登录密码
     * @param nextPassword  确认密码
     * @param code          验证码
     * @return
     */
    public PostRequest<HttpData> forgetPassword(String number, String loginPassword, String nextPassword, String code) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.FORGET_PASSWORD)
                .params("mobile", number)
                .params("opwd", loginPassword)
                .params("opwd1", nextPassword)
                .params("code", code);
    }

    /**
     * 取消点赞或点赞
     *
     * @param is_like 1.点赞2.取消
     * @param msg_id  文章Id
     * @return
     */
    public PostRequest<HttpData> setLike(String is_like, String msg_id) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.COMMUNITY_SET_LIKE)
                .params("is_like", is_like)
                .params("type", "1")
                .params("msg_id", msg_id);
    }

    public PostRequest<HttpData<TextDetailsBean>> getTextDetails(String msg_id) {
        return OkGo.<HttpData<TextDetailsBean>>post(HttpConfig.BASE_URL + HttpConfig.COMMUNITY_TEXT_DETAILS)
                .params("msg_id", msg_id);
    }
    /**
     * 分享 生成APP下载二维码
     *
     * @return
     */
    public PostRequest<HttpData<ShareBean>> getShareInfo() {
        return OkGo.post(HttpConfig.BASE_URL + HttpConfig.SHARE_INFO);
    }

    /**
     * 发表文章
     *
     * @param title   标题
     * @param content 文章
     * @return
     */
    public PostRequest<HttpData> setTextSubmit(String title, String content) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.COMMUNITY_SUBMIT_TEXT)
                .params("title", title)
                .params("content", content);
    }

    /**
     * 获取验证码
     *
     * @param number
     * @param type
     * @return
     */
    public PostRequest<HttpData> getCode(String number, String type) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.GET_CODE)
                .params("mobile", number)
                .params("type", type);
    }

    /**
     * 注册
     *
     * @param yq     邀请码
     * @param number 手机号
     * @param code   验证码
     * @param pwd    密码
     * @param tpwd   资金密码
     * @return
     */
    public PostRequest<HttpData> register(String yq, String number, String code, String pwd, String tpwd) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.REGISTER)
                .params("tjuser", yq)
                .params("mobile", number)
                .params("code", code)
                .params("opwd", pwd)
                .params("tpwd", tpwd);
    }

    /**
     * 设置头像
     *
     * @param head 头像文件
     * @return
     */
    public PostRequest<HttpData> uploadHead(File head) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.UPLOAD_HEAD)
                .params("upic", head);
    }

    /**
     * 设置昵称
     *
     * @param nickname
     * @return
     */
    public PostRequest<HttpData> setNickName(String nickname) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.SET_NICKNAME)
                .params("nickname", nickname);
    }

    /**
     * 身份认证状态
     *
     * @return
     */
    public PostRequest<HttpData<CertificationBean>> getCertificationStatus() {
        return OkGo.post(HttpConfig.BASE_URL + HttpConfig.CERTIFICATION_STATUS);
    }

    public PostRequest<HttpData<List<FunctionsBannerBean>>> getBanner() {
        return OkGo.<HttpData<List<FunctionsBannerBean>>>post(HttpConfig.BASE_URL + HttpConfig.FUNCTIONS_BANNER);
    }

    public PostRequest<HttpData<ArticleBean>> getArticleData(String id) {
        return OkGo.<HttpData<ArticleBean>>post(HttpConfig.BASE_URL + HttpConfig.CERTIFICATION_ARTICLE)
                .params("id", id);
    }

    /**
     * 投资页面余额
     *
     * @param id
     * @return
     */
    public PostRequest<HttpData<UsableBean>> getUsable(String id) {
        return OkGo.<HttpData<UsableBean>>post(HttpConfig.BASE_URL + HttpConfig.USABLE)
                .params("id", id);
    }

    /**
     * 协议
     *
     * @param type
     * @param languages
     * @return
     */
    public PostRequest<HttpData> getAgreement(String type, String languages) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.FUNCTIONS_AGREEMENT)
                .params("type", type)
                .params("languages", languages);
    }

    /**
     * 活期宝币种
     *
     * @return
     */
    public PostRequest<HttpData<List<String>>> getCoinList() {
        return OkGo.post(HttpConfig.BASE_URL + HttpConfig.GET_HUOQI_COINS);
    }

    /**
     * 投资返利列表
     *
     * @param orderId 订单id
     * @param page
     * @param size
     * @return
     */
    public PostRequest<HttpData<PageBean<IncomeDetailBean>>> getIncomeList(String orderId, int page, int size) {
        return OkGo.<HttpData<PageBean<IncomeDetailBean>>>post(HttpConfig.BASE_URL + HttpConfig.INCOME_LIST)
                .params("id", orderId)
                .params("page", page)
                .params("size", size);
    }
}
